<?php

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'sn_blocks/misc/misc_constants.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

if ($user->data['user_id'] == ANONYMOUS)
{
	login_box('', 'LOGIN');
}

$user_id = request_var('u', 0);
$text_empty = (bool) request_var('text', 1);
if ($user_id != $user->data['user_id'])
{
	redirect(append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&amp;u='.$user_id));
}

$misc_text = request_var('misc_text', '', true);

$uid = $bitfield = $options = '';
$allow_bbcode = $allow_urls = $allow_smilies = true;

generate_text_for_storage($misc_text, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);

$sql_ary = array(
	'user_id'					=> $user_id,
	'bbcode_uid'				=> $uid,
	'bbcode_bitfield'			=> $bitfield,					
	'bbcode_options'			=> $options,
	'profile_info_block'		=> $misc_text,
);

if ($text_empty == true)
{
	$sql = 'INSERT INTO ' . SN_MISC_BLOCK_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
	$db->sql_query($sql);
}
else
{
	$sql = 'UPDATE ' . SN_MISC_BLOCK_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary);
	$db->sql_query($sql);
}

redirect(append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&amp;u='.$user_id));

?>